﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lm.Common.DAL.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            var con = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            var helper = new Lm.Common.DAL.Sql.SqlDAL(con);
            //增
            var id = helper.Insert<test>(() => new test() { Name = "tom" });
            var id2 = helper.Insert<test>(new test() { Name = "jim" });
            //删
            helper.Delete<test>(t => t.Name == "tom");
            //改
            helper.Update<test>(t => new test() { Name = "jim2" }, t => t.Name == "jim");
            helper.Update<test>(new test() { Id = 300001, Name = "jim3" }, t => t.Name == "jim2");
            //查
            var list = helper.Select<test>(t => t.Name == "jim3");
            var list2 = helper.Select<test>(() => new test() { Name = "" }, () => new test() { Id = 0 }, OrderByOption.ASC, t => t.Name == "jim3");
            long recordCount;
            var list3 = helper.Select<test>(1, 1, out recordCount, () => new test() { Name = "" }, () => new test() { Id = 0 }, OrderByOption.ASC, t => t.Name == "jim3");
        }
    }
    class test : Lm.Common.DAL.IModelBase
    {
        [Lm.Common.DAL.Identity]
        public long Id { get; set; }
        public string Name { get; set; }
    }
}
